import java.io.File;
import java.io.RandomAccessFile;



public class ReadHeader  {


	String[] temp2;

	/*
	 * reading the header of the heap file
	 * and converting into an array which is
	 * used for further analysis in the code.
	 */
	public String[] read(String path) throws Exception{

		String str="";
		heap.f=new File(path);
		if(heap.f.exists())
		{
			RandomAccessFile fip= new RandomAccessFile(heap.f, "rw");
			fip.seek(0);
			int i=0;
			char c;
			int k=0;
			while((c =(char) fip.readByte())!=',')
			{	
				str+=c;
				k++;
			}
			i=Integer.parseInt(str);
			int j=0;
			str="";
			while(j<i)
			{
				str+=(char)fip.readByte();
				j++;
			}
			//System.out.println(str);
			temp2=str.split(",");

			heap.readpointer=(i+k+1);
			heap.headerLength = heap.readpointer;
			return temp2;
		}
		else
			throw new Exception("File not found");
	}
}
